PyPDF2 Metadata
读取:
from PyPDF2 import PdfReader
reader = PdfReader("example.pdf")
meta = reader.metadata
print(len(reader.pages))
# All of the following could be None!
print(meta.author)
print(meta.creator)
print(meta.producer)
print(meta.subject)
print(meta.title)
写入:
from PyPDF2 import PdfReader, PdfWriter
reader = PdfReader("example.pdf")
writer = PdfWriter()
# Add all pages to the writer
for page in reader.pages:
writer.add_page(page)
# Add the metadata
writer.add_metadata(
{
"/Author": "Martin",
"/Producer": "Libre Writer",
}
)
# Save the new PDF to a file
with open("meta-pdf.pdf", "wb") as f:
writer.write(f)
本文作者:Maeiee
本文链接:PyPDF2 Metadata
版权声明:如无特别声明,本文即为原创文章,版权归 Maeiee 所有,未经允许不得转载!
喜欢我文章的朋友请随缘打赏,鼓励我创作更多更好的作品!